package com.chris.libs.example.pages.ext.recyclerview;

import android.content.Context;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.recyclerview.widget.RecyclerView;

import com.chris.libs.base.x.mvpp.recycler.BaseRecyclerHolder;
import com.chris.libs.base.x.mvpp.viewholder.BaseViewHolder;
import com.chris.libs.example.R;
import com.chris.libs.example.model.DataItem;

import javax.inject.Inject;

import butterknife.BindView;

/**
 * @author Chris chan
 * Create on： 2025/2/2 18:20
 * Use for:
 * Explain:
 */
public class RecyclerViewExampleViewHolders {
    /**
     * 界面主要布局ViewHolder
     */
    public static class MainViewHolder extends BaseViewHolder {
        // 界面元素实例列表
        @BindView(R.id.rv_data)
        public RecyclerView rvData;

        // Dagger2 注入构造函数
        @Inject
        public MainViewHolder() {
        }
    }

    /**
     * RecyclerView列表项ViewHolder
     */
    public static class DataItemViewHolder extends BaseRecyclerHolder<DataItem> {
        // 界面元素实例列表
        @BindView(R.id.tv_title)
        TextView tvTitle;
        @BindView(R.id.iv_icon)
        ImageView ivIcon;

        public DataItemViewHolder(Context context, View itemView) {
            super(context, itemView);
        }

        /**
         * 更新视图
         *
         * @param item
         */
        @Override
        public void refreshView(DataItem item) {
            tvTitle.setText(item.getTitle());
            ivIcon.setImageResource(item.getIcon());
        }
    }
}
